package mcommand;

import java.awt.Graphics2D;

/**
 * Handles how the users missiles are animated on the board also handles the
 * drawing of the explosion shape and the target cross for the users missiles.
 * 
 * @author Marcel, Christian, Klaus
 */
public class AllyMissile extends Missile {
    // move speed for the user missiles
    private final static float ALLYMISSILE_SPEED = 0.02f;

    /**
     * defines the standard start position and the move speed of the missile.
     *
     * @param board
     *            responsible board
     */
    public AllyMissile(final Board board) {
        // defines standard values for the starting positions
        start_x = 0;
        start_y = 0;

        // defines the move speed of the missile
        move_speed = ALLYMISSILE_SPEED;
    }

    @Override
    public final void paint(final Graphics2D g2d) {
        // if missile state is FLYING
        if (ms == MissileState.FLYING) {

            // draws a line with the start positions and the current end
            // positions
            g2d.drawLine(start_x, start_y, getX(), getY());

            // draws the target cross on the target position of the missile
            g2d.drawImage(targetCross,
                    (target_x - (targetCross.getWidth(null) / 2)),
                    (target_y - (targetCross.getHeight(null) / 2)), null);

            // if missile state is DESTROYED
        } else if (ms != MissileState.DESTROYED) {

            // calls the method of missile to get the explosion shape to draw
            g2d.draw(getExplosionShape());
        }
    }
}
